home *** CD-ROM | disk | FTP | other *** search
/ Informática Multimedia 1995 April / Informatica Multimedia CD - Epimundo.iso / DOS / FILEVIEW / HEAD.ZIP / HEAD.DOC < prev    next >
Encoding:
Text File  |  1986-04-28  |  8.2 KB  |  180 lines

  1.                                     HEAD
  2.                               by  John Simonson
  3.  
  4.          HEAD.EXE will display the first 5 lines (by default) of specified
  5.          text files.  There are several switches that allow you to control
  6.          the output.
  7.  
  8.          I wrote HEAD because of a terrible mistake I made.  I had files on
  9.          my Winchester drive that I had not backed up; one of these files was
  10.          a 20 page document that was very important.  Of course the hard disk
  11.          crashed (of course at 2 mins. before quitting time on a Friday
  12.          night...), and was so badly scrambled, that I had to clean out the
  13.          disk with CHKDSK /F and then go through the resulting 2 meg of
  14.          FILE????.CHK files (each file between 2 and 12K in size).
  15.  
  16.          After writing a routine to discover which of these files were pieces
  17.          of binary files (i.e., largely non-printable ascii stuff) and
  18.          deleting them, I still had a large number of files to go through and
  19.          figure out which files could be used to recreate the important
  20.          document.  With HEAD I can list out the file names and the first few
  21.          lines of each file, and by referring to the printed copy of the
  22.          original document (yes, at least I had that) I could determine the
  23.          correct order in which to append files.
  24.  
  25.          HEAD may be invoked as follows:
  26.  
  27.          HEAD filespec [-L [-T [-H [-N [-#]]]]]
  28.  
  29.          The option switches may appear in any order, and may precede or
  30.          follow the file specification.  The switches may be in upper or
  31.          lower case, and MUST be preceded (without intervening spaces) by
  32.          either a dash (-) or a slash (/).  The file specifications may
  33.          include any valid drive, optionally followed by any valid directory
  34.          specifications, followed by any valid file name with extension.  The
  35.          file name and extension may contain wildcards.  HEAD will not accept
  36.          the slash (/) as subdirectory separator, which may cause you grief
  37.          if you have specified the SWITCHAR as the dash (-) in your
  38.          CONFIG.SYS.  I may change this to allow only the (-) as an option
  39.          flag and either (\) or (/) as the subdirectory separator in the next
  40.          version of HEAD.
  41.  
  42.          The options you may select from are:
  43.  
  44.          -h Print a file name header for each file displayed.  Each file
  45.          displayed will be preceded by a line containing the file name, and a
  46.          blank line.
  47.  
  48.          -l Print the line number with each line displayed.
  49.  
  50.          -n End each line displayed with an additional newline.
  51.  
  52.          -t Translate down (by decimal 128) all ascii characters with an ascii
  53.          value greater than 127 (decimal).  This effectively removes the soft
  54.          carriage returns (ascii 141) produced by many word processors, and
  55.          other such things that don't always display nicely to the screen.
  56.          This does NOT mean that a soft carriage return will be replaced with
  57.          a hard carriage return AND line feed; this is only a simple shifting
  58.          down of the ascii value of existing characters.
  59.  
  60.          -# Don't really enter the number sign (#); rather, enter the number
  61.          of lines you wish displayed from each file.  The default value is
  62.          set to 5.
  63.  
  64.          You may enter the options together (e.g., -hl20) or separately
  65.          (e.g., -h -l -20).  If entered separately, each switch must be
  66.          preceeded by a space and a switch character (- or /).  The command
  67.          line is scanned for ALL option switches first, so options may
  68.          preceed or follow or be interspersed with the file specifications.
  69.  
  70.          You must enter a file specification!  The program will stop with a
  71.          usage message if you fail to give it a file specification.  You may
  72.          give it more than one file specification.  HEAD will expand all
  73.          wildcard specifications, unless it is unable to find any files
  74.          matching the specification.  In that case, it will report (e.g. for
  75.          HEAD *.bak)
  76.  
  77.          "HEAD: could not find any file *.bak"
  78.  
  79.          There is a similar caveat for the specification of the number of
  80.          lines to be printed -- if you specify this option more than once,
  81.          the last specification is used, the others are discarded.
  82.  
  83.  
  84.                                     HEAD  page 2
  85.  
  86.          You may also redirect the output, to a printer or to a file, e.g.,
  87.  
  88.          HEAD bozo.dat -l -h > prn
  89.  
  90.          to send output to the printer.  You should also be able to pipe
  91.          output to other programs (e.g., HEAD -10 *.DOC | SORT)
  92.  
  93.          The following examples may be of some help.
  94.  
  95.          HEAD -l -15 E:\CLIB\SOURCE\*.C -h
  96.  
  97.          would display the first fifteen (-15) lines with line numbers (-l)
  98.          of all files ending with the extension ".C" on drive E in the
  99.          subdirectory SOURCE of the subdirectory CLIB, preceding each file's
  100.          output with a header line giving the file name.
  101.  
  102.          HEAD autoexec.ba?
  103.  
  104.          would display the first 5 lines (the default) of all files on the
  105.          default drive and current directory with a name of "autoexec" and an
  106.          extension that begain with ".ba" (e.g., .BAK and .BAT).
  107.  
  108.          HEAD *.doc -20 -t -8  or  HEAD -20 *.doc -t8  or  HEAD -20t8 *.doc
  109.  
  110.          would list the first 8 lines of all files with the extension ".DOC"
  111.          on the current drive and directory.  Note that the -20 is ignored,
  112.          the -8 is accepted since it is the most recent setting specified.
  113.          All characters greater than 127 decimal ascii value would be
  114.          translated down by decimal 128.
  115.  
  116.          HEAD -h -l
  117.  
  118.          would produce an error message, informing you that you must specify
  119.          a file or files.
  120.  
  121.          HEAD
  122.  
  123.          would produce a usage message, telling you what it wants.
  124.  
  125.          HEAD file1.txt file2.txt
  126.  
  127.          would display the first 5 lines (default) of file1.txt, with no
  128.          header line, and no line numbers, followed immediately by the first
  129.          5 lines of file2.txt.
  130.  
  131.          HEAD -h nosuch.fil
  132.  
  133.          assuming "nosuch.fil" does not exist, HEAD will tell you it couldn't
  134.          find file nosuch.fil.
  135.  
  136.          HEAD was written in C and originally compiled using Computer
  137.          Innovation's C86 compiler (v 2.30), which seems to be a very nice
  138.          compiler.  The current version (2.1) was compiled using Microsoft C
  139.          version 3.0 which produces smaller code.
  140.  
  141.          DISCLAIMER: I can't promise that the program will work as you expect
  142.          it to; I've had few problems with it.  This is really the first
  143.          version, and I'm sure as it is used, people will find things that it
  144.          could do better, or correctly, etc..  Feedback is welcome.  It
  145.          probably won't melt your machine not a pool of liquid silicon, but
  146.          then again...
  147.  
  148.          NOTE: This program is copyrighted, but may be used, shared, and
  149.          copied freely, as long as no charge is made for the program itself.
  150.          I don't want any money for it (well, I could be persuaded....).
  151.  
  152.          John Simonson
  153.          Department of Psychology
  154.          University of Rochester
  155.          Rochester, NY  14627
  156.  
  157.  
  158.  
  159.  
  160.                    This disk copy provided as a service of
  161.  
  162.                         The Public (Software) Library
  163.  
  164.                            the software library of
  165.                      The Houston Area League of PC Users
  166.  
  167.          Program disks are available for as little as $2 each and a
  168.          20-page monthly newsletter reviewing all the latest public
  169.          domain and shareware software plus a listing of all the
  170.          disks in our library is available for just $12 a year.
  171.  
  172.          For a copy of the latest monthly software library newsletter
  173.          and program directory, send a self-addressed, stamped (with
  174.          two stamps), legal-size envelope or send $1 to
  175.  
  176.                         The Public (Software) Library
  177.                                 P.O.Box 61565
  178.                                    Dept. D
  179.                               Houston, TX 77208
  180.